/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-04-18 23:40:31
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.core.entity;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_base_role_user_login_role")
@Data
public class BaseRoleUserLoginRole implements java.io.Serializable {

    // columns START

    // 登录用户ID
    @Column(name = "USER_ID")
    private Long userId;

    // 角色ID
    @Column(name = "ROLE_ID")
    private Long roleId;

    // 租户
    @Column(name = "TENENT_ID")
    private Long tenentId;

    //
    // @Column(name = "login_user_id")
    // private Long loginUserId;

    // 组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;
    // columns END

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BaseRoleUserLoginRole == false)
            return false;
        if (this == obj)
            return true;
        BaseRoleUserLoginRole other = (BaseRoleUserLoginRole) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
